<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
  <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>商品管理</li>
    <li>修改</li>
  </ul>
</div>
<div class="formbody">
  <form action="/erp/purchase/product/doupdate" method="post">
    <input type="hidden" name="productId" th:value="${Pedit.productId}" class="dfselect">
  <div class="formtitle"><span>商品信息</span></div>
  <ul class="forminfo">
    <li>
      <label>品牌名称</label>
      <select name="brandBId" onchange="getType(this.value)" class="dfselect">
      	  <option value="0">请选择</option>
        <option th:each="b:${session.brands}" th:text="${b.brandName}" th:value="${b.brandId}" th:selected="${b.brandId==Pedit.types.cBrand.brandId}"></option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>商品类型</label>
      <select name="typeId" class="dfselect">
      	  <option value="0">请选择</option>
        <option th:each="t : ${typesa}" th:value="${t.typeId}" th:text="${t.typeName}" th:selected="${Pedit.typeId==t.typeId?true:false}"></option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>商品型号</label>
      <input name="productModel" type="text" th:value="${Pedit.productModel}"  class="dfinput" />
      <i>必填，不能超过50个字符</i>
    </li>
    <li>
      <label>单位</label>
      <input name="productUnit" type="text" value="台" th:value="${Pedit.productUnit}" class="dfinput" />
      <i>必填，不能超过10个字符</i>
    </li>
    <li>
      <label>状态</label>
      <select name="productStatus" class="dfselect">
        <option value="0">请选择</option>
        <option value="1" th:selected="${Pedit.productStatus==1}?'true':'false'">可用</option>
        <option value="2" th:selected="${Pedit.productStatus==2}?'true':'false'">不可用</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>创建人</label>
      <input name="createId" type="hidden" th:value="${session.currUser.uId}">
      <input  type="text" th:value="${session.currUser.uname}" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>创建时间</label>
      <input name="createTime" type="text" th:value="${#dates.format(Pedit.createTime,'yyyy-MM-dd HH:mm:ss')}" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="submit" class="btn" value="确定"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='/erp/purchase/product/cplist'"/>
    </li>
  </ul>
  </form>
</div>
<script>
  function getType(num) {
    $.get("/erp/ajaxType",{"bid":num},function (data) {
      console.log(data);
      $("select[name=typeId]").html("");
      var options="<option value=''>请选择</option>";
      $.each(data,function (i,e) {
        if(e.typeId==$("#typeiD").val()){
          options+="<option value='"+e.typeId+"' selected>"+e.typeName+"</option>";
        }else{
          options+="<option value='"+e.typeId+"'>"+e.typeName+"</option>";
        }

      });
      $("select[name=typeId]").append(options);
    },"json");
  }
</script>
</body>
</html>
